import request from '@/utils/request';
import type { BaseBeanModel, ResponsePageData, ResponseBaseData, QueryParamModel } from '@/api/model/baseModel';
import type { downloadParam } from '@/utils/download-util';
import { download } from '@/utils/download-util';
const basePath = '/appsys/sysserviceconfigs';
/** 服务注册 */
export interface SysServiceConfigDto extends BaseBeanModel {
  /** 服务编码 */
  serviceCode?: string;
  /** 服务名称 */
  serviceName?: string;
  /** 服务地址 */
  serviceUrl?: string;
  /** 描述 */
  serviceRemarks?: string;
}

/** 获取分页数据 */
export function listSysServiceConfigByPage(param: QueryParamModel): Promise<ResponsePageData<SysServiceConfigDto>> {
  return request.post(`${basePath}/find-list-by-page/v1`, param);
}

/** 根据id加载数据 */
export function getSysServiceConfig(id: string): Promise<ResponseBaseData<SysServiceConfigDto>> {
  return request.get(`${basePath}/get/${id}/v1`);
}

/** 保存表单数据 */
export function saveSysServiceConfig(form: SysServiceConfigDto): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/save/v1`, form);
}

/** 根据id集合删除数据 */
export function delSysServiceConfig(ids: [string]): Promise<ResponseBaseData<any>> {
  return request.delete(`${basePath}/delete-by-ids/v1`, { data: ids });
}

/** 校验服务编码唯一性 */
export function checkServiceCodeUnique(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/check-service-code-unique/v1`, param);
}

/** 测试连接 */
export function testSysServiceConnection(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/test-connection/v1`, param);
}

/** 导出xml */
export function exportXml(param: any) {
  const params = {
    url: `${basePath}/export-xml/v1`,
    data: param,
    method: 'post'
  } as downloadParam;
  return download(params);
}
